
<template comments>
  <div class="pharmacy"> 
    <TopManu :signOut="true"  @handleQuit="$router.go(-1)" ></TopManu>
  
    <div class="search">
      <div >
        <el-input
          v-model="params.keyword"
          placeholder="请输入关键词"
        ></el-input>
       
           <el-button @click="searchB()" class="butB_Sel">查询</el-button>
           <el-button @click="addBeiAn()" class="butB_Sel">慢特病备案</el-button>
             <el-button @click="yibao_show2=true" class="butB_Sel">查询慢特病治疗方案</el-button>
       <el-button @click="daochu" class="butB_Sel">导出</el-button>
     
      </div>
      
    </div>

    <div class="tablesB">
      <el-table  v-loading="params.loading" :data="data" border >
        <el-table-column type="index" width="70" label="序号">
        </el-table-column>
        <template v-for="(item, index) in $baseBai['mantebing']['list']">

  <el-table-column :width="item.width" v-if="item.prop == 'status'" :prop="item.prop" :label="item.label" :key="index">
                        <template slot-scope="scope">
                            <div v-if="scope.row.status==1">正常</div>
                            <div v-if="scope.row.status==2">撤销</div>
                        </template>
              </el-table-column>
              
  <el-table-column :width="item.width" v-else-if="item.prop == 'treatment_status'" :prop="item.prop" :label="item.label" :key="index">
                        <template slot-scope="scope">
                            <div v-if="scope.row.treatment_status==1">已备案</div>
                            <div v-if="scope.row.treatment_status==2">未备案</div>
                        </template>
              </el-table-column>
            
              
            <el-table-column v-else   :width="item.width" :prop="item.prop" :label="item.label" :key="index+item"> </el-table-column>
           </template>
            <el-table-column label="更多" width="350" fixed="right"    >
              <template slot-scope="scope">

                 <div>
                   <el-button
                     size="mini"
                    type="danger"
                    @click="handleEdit(scope.$index, scope.row,1)">撤销备案</el-button>
                     <el-button
                     size="mini"
                  
                    @click="handleEdit(scope.$index, scope.row,2)">治疗方案</el-button>
                      <el-button
                     size="mini"
                    type="danger"
                    @click="handleEdit(scope.$index, scope.row,3)">撤销方案</el-button>
                 </div>
              </template>
            </el-table-column>
      
      </el-table>
        <div>
           <el-pagination
           class="fenye"
            :background="true"
            :current-page="params.page"
            :page-size="params.limit"
            layout="prev, pager, next"
            @current-change="handlePagination"
            :total="params.pageCount">
            </el-pagination>
      </div>
    </div>


      <el-dialog
        title="备案"
         :destroy-on-close	="true"
         v-if="yibao.show"
        :visible.sync="yibao.show"
         :close-on-click-modal="false"
        width="30%"
        :before-close="()=>{this.yibao.show=!this.yibao.show}">
             <yibaoInfo :dialogTitle='dialogTitle' :thatF="this"></yibaoInfo>
      
      </el-dialog>
          <el-dialog
        title="慢特病治疗方案"
         :destroy-on-close	="true"
     
        :visible.sync="yibao_show"
         :close-on-click-modal="false"
        width="30%"
        :before-close="()=>{this.yibao_show=!this.yibao_show}">
             <fangan :id="mt_id"></fangan>
      
      </el-dialog>
          <el-dialog
        title="慢特病治疗方案"
         :destroy-on-close	="true"
         v-if="yibao_show2"
        :visible.sync="yibao_show2"
         :close-on-click-modal="false"
    
        :before-close="()=>{this.yibao_show2=!this.yibao_show2}">
             <yibaoInfocode :dialogTitle='dialogTitle' :thatF="this"></yibaoInfocode>
      
      </el-dialog>
  </div>
</template>

<script>
let t;
import yibaoInfo from './common/yibaoInfo'
import {http} from "@/utils/server.js"
import yibaoInfocode from './common/yibaoInfocode'
import fangan from './common/updateChufang'
import TopManu from "@/components/TopMenu";
import {downChronicMember}from "@/api/zhuyanre";
import { mapState,mapActions } from "vuex";
// getDict_dataKuFangList
export default {
  name:"chronicIdiopathicDisease",
  data() {
    return {
      Detail_Show:false,
      tableTitle: [],
      dialogTitle:'',
     mt_id:'',
     yibao_show:false,
     yibao_show2:false,
      params: {
        loading:false, 
       
        page:1,
        limit:10,
       keyword:'',
       pageCount:0,
      },
      beian:{
        show:false,
      },
      yibao:{
        show:false,
      },
      
    
      data: [],
    };
  },
  components: {
    TopManu,    
    yibaoInfo,
    fangan,
    yibaoInfocode
  },
 
  mounted() {
    t = this;


      t.getList()
   
  },
    computed: {
    ...mapState({
      dict_psn_cert_type: state => state.dictBai.dict_psn_cert_type,
      dict_naty: state => state.dictBai.dict_naty,
     
    }),
  },
  methods: {
     ...mapActions([
            'dictBai/getDict_dataDictIndex',,
         
       
			]),
      addBeiAn(){

           if(this.dict_psn_cert_type.length<=0&&this.dict_naty.length<=0){
                           return   this['dictBai/getDict_dataDictIndex']({group_id:'64,37,13,14'}).then(res=>{

                                          this.yibao.show=true;
                        
                          })
                      }else{
                        this.yibao.show=true;
                      }
       
      },
       daochu(){
            
      downChronicMember()
      .then(res=>{
        window.open(http + '/' +res.data.file_url);
      }) 
      .catch(e=>{
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
      },
     handleEdit(...item){
       if(item[2]==1){
          
           t.$prompt('请输入撤销原因', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          beforeClose: (action, instance, done) => {
         
            if (action === 'confirm') {
               
                if(!instance.inputValue){
                 this.$message.error('请输入撤销原因');
                }else{
                   done()
                }
            }else{
              done()
            }
          },
        }).then(({ value }) => {
             let d={id:item[1].id,remark:value}
            t['_API'].getclinic_ybBackPsnSlowDisease(d).then(res=>{
                if(res.code==200){
                    this.$message({
                                        message: res.message,
                                        type: 'success'
                                    });
                                    this.params.page=1;
                                    this.getList()
                }
                console.log(res)
              })
           
        })
          
      

          
       }else if(item[2]==2){
         this.yibao_show=true
         this.mt_id=item[1].id
       }else if(item[2]==3){
         
            t.$prompt('请输入撤销原因', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          beforeClose: (action, instance, done) => {
         
            if (action === 'confirm') {
               
                if(!instance.inputValue){
                 this.$message.error('请输入撤销原因');
                }else{
                   done()
                }
            }else{
              done()
            }
          },
        }).then(({ value }) => {
             let d={id:item[1].id,remark:value}
            t['_API'].backPsnSlowDiseaseTreatment(d).then(res=>{
                if(res.code==200){
                    this.$message({
                                        message: res.message,
                                        type: 'success'
                                    });
                                    this.params.page=1;
                                    this.getList()
                }
                console.log(res)
              })
           
        })
       }
     },
      
     
  
  
    
    searchB() {
     
      t.params.page=1;
      t.getList()
    },

 
     handlePagination(e){
       
         t.params.page=e;
        t.getList()
        
    },
    getList(){
     
      let d={
       
        limit:t.params.limit,
        page:t.params.page,
        keyword:t.params.keyword,
        
      }
      t.data=[];
       this.params.loading=true;
      this['_API'].getmemberChronicMember(d).then(res=>{
         this.params.loading=false;
                 if(res.code==200){
                   
                     
                        this.data=res.data.list;
                        this.params.pageCount =res.data.count;
                       
                 }
      })
      
    },
  },
};
</script>

<style lang="scss" scoped>
/deep/ .el-tabs__nav {
  
  .el-tabs__item {
    border-bottom: 1px solid #e4e7ed;
  }
  .is-active {
    color: #02bf6b;
  }
  .el-tabs__item:hover {
    color: #02bf6b;
  }
}
.search {
  border: 1px solid #f2f2f2;
  margin: 10px 2%;
  padding: 20px;
  border-radius: 10px;
  .s1 {
    width: 300px;
    display: flex;
    .el-input{
      margin-right: 10px;
    }
    button {
      margin-left: 20px;
      margin-bottom: 20px;
      color: white;
    }
  }
  .selectBai {
    display: flex;
    > div {
      margin-right: 10px;
    }
  }
}

.tableMore {
  /deep/ .el-button--primary {
    color: black;
    background-color: initial;
    border-color: #e2e2e2;
  }
}
.tablesB,.tabsB{margin: 20px 2% 0;}

  .fenye{
    text-align: right;
    margin-top: 20px;   
    
  }
  /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active{
      background-color: #02bf6b;
  }

  
  /deep/ .el-dialog__body {
   background-color: white;
  overflow: scroll;
}
/deep/ .el-dialog{
        width: 100% !important;
        margin-top:0 !important;
         height: 100vh;
       
  }
</style>